import { Component, OnInit } from "@angular/core";
import { Router } from "@angular/router";
import { FormBuilder, Validators } from "@angular/forms";
import { ApiService } from "../../../core/api/api.service";
import { MessageService } from "../../../core/service/message.service";
import { NzMessageService, NzModalService } from "ng-zorro-antd";
import { DatePipe } from "@angular/common";

/**
 * 任务管理-任务列表
 */

@Component({
    templateUrl: "./taskList.html",
})
export class TaskListComponent implements OnInit {
    pages = {
        pageNo: 1,
        pageSize: 10,
        total: 0,
        name: "",
        type: "",
        status: "",
        beginTime: "",
        endTime: "",
    };
    dataList = [];
    tableLoading = false;
    dateRange;
    ngOnInit() {
        this.loadList();
    }
    constructor(
        private router: Router,
        private fb: FormBuilder,
        private apiService: ApiService,
        private message: MessageService,
        private nzMessageService: NzMessageService,
        private modal: NzModalService,
        private datePipe:DatePipe
    ) {}
    onChange(value) {
        console.log(value);
        if(value&&value.length === 2){
            this.pages.beginTime = this.datePipe.transform(value[0],'yyyy-MM-dd');
            this.pages.endTime = this.datePipe.transform(value[1],'yyyy-MM-dd');
        }
    }
    loadList() {
        this.apiService.post("任务列表", this.pages).then((res: any) => {
            this.dataList = res.data.list;
        });
    }
}
